import SoundUtil from "../../Fantasy/Util/SoundUtil";

// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class StarExplain extends cc.Component {

    @property(cc.Sprite)
    face: cc.Sprite = null;
    @property(cc.Sprite)
    back: cc.Sprite = null;

    status = 1;
    setStarInfo(starCardName){
        Log(starCardName);
        LoadResImg(this.face,'Texture/星座卡片正面/'+starCardName);
        LoadResImg(this.back,'Texture/星座卡片背面/'+starCardName);
        this.face.node.scaleX = 1;
        this.back.node.scaleX = 0;
        this.status = 1;
    }

    btnCallback(){
        SoundUtil.playEffect("music/click");
        if (this.status == 1){
            this.status = 2;
            this.face.node.runAction(cc.sequence(
                cc.scaleTo(0.1,0,1),
                cc.callFunc(()=>{
                    this.back.node.runAction(cc.sequence(
                        cc.scaleTo(0.1,1,1),
                        cc.callFunc(()=>{

                        })
                    ))
                })
            ))
        }
        else{
            this.node.destroy();
        }
    }
}
